use strict;
use warnings;

use CPAN;
use CPAN::Config;

# The following is an attempt to install cpan modules
# for a project with a large number of dependencies at one go,
# in a way that provides easy debugging when things go wrong.
# In practice, this script may not always succeed at one go.
# It may have to be run repeatedly, some modules may have to be installed manually, etc.
# While not perfect, however, it is a good deal better to at least attempt to 
# keep things centralized in this fashion than writing down lists of dependencies
# on little scraps of paper -- or not at all. :)
# Happy installling.

use ModuleList;
my $modulelist = ModuleList->new();
use CPANStuff;
my $cpanstuff = CPANStuff->new();

# Setting the FTP_PASSIVE=1 environment variable avoids another common problem 
# where active File Transfer Protocol (FTP) connections are blocked by a local firewall.
# http://sial.org/howto/perl/life-with-cpan/
$ENV{FTP_PASSIVE}=1;

for my $mod ( my @regular_modules = $modulelist->get_modules() ) {
    $cpanstuff->install_wrapper($mod);
}

#my $input;

#print
#"Do you want to force install modules that don't install smoothly the usual way?
#(the usual way = perl -MCPAN -e 'install mymod')
#This could take a while, so only answer \"yes\" if you're running for the first time
#or there is a new module to force install.
#[yes/no] ";
#$input = <STDIN>;
#chomp $input;
#if ($input eq 'yes') {
    for my $force_mod ( my @force_mods = $modulelist->get_modules_need_force() ) {
        $cpanstuff->force_install_wrapper($force_mod);
    }
#}

